﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Objects Exercise 2</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Function that removes all elements with a given value.</h1>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        Array.prototype.remove = function removeValue(value) {
            for (var idx = 0; idx < this.length; idx++) {
                if (this[idx] === value) {
                    this.splice(idx, 1);
                    idx--;
                }
            }
        }

        var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, "1"];

        jsConsole.writeLine("Original: " + arr);
        arr.remove(1);
        jsConsole.writeLine("Changed: " + arr);
       
    </script>
</body>
</html>
